<!--页面组件-->
<template>
  <div>
    <div class="tempxyz">
      <CCard class>
        <CCardHeader>
          <span class="headerFont">
            <img
              @click="goBack"
              src="@/assets/icons/goback.svg"
              alt
              class="goBtn"
            />
            {{ groupTaskName }}的子任务列表
          </span>
        </CCardHeader>
        <CCardBody>
          <CCol class="titleCol">
            <div>
              <p class="myColPri" style>任务状态</p>
              <RadioGroup v-model="taskStatus">
                <Radio label>全部</Radio>
                <Radio label="1">执行中</Radio>
                <Radio label="8">待执行</Radio>
                <Radio label="4">成功</Radio>
                <Radio label="5">失败</Radio>
                <!--  <Radio label="2">暂停</Radio>-->
                <Radio label="7">停止</Radio>
                <Radio label="10">部分失败</Radio>
              </RadioGroup>
            </div>
            <div>
              <CButton
                class="btn_style system-btn-style"
                id="restartId"
                color="info"
                @click="updateStatus('retry')"
                data-permission="Btn_TaskCenter_Retry"
              >
                <img
                  src="@/assets/icons/restart.svg"
                  class="imgstyle"
                  alt
                />&nbsp;重试
              </CButton>

              <!-- <CButton
                class="btn_style system-btn-style"
                color="info"
                @click="pauseAndResume('pause')"
                data-permission="Btn_TaskCenter_Pause"
              >
                <span>
                  <img
                    src="@/assets/icons/pause.svg"
                    class="imgstyle"
                    alt
                  />&nbsp;暂停 &nbsp;
                </span>
              </CButton>
              <CButton
                class="btn_style system-btn-style"
                color="info"
                @click="pauseAndResume('resume')"
                data-permission="Btn_TaskCenter_Pause"
              >
                <span>
                  <img
                    src="@/assets/icons/retry.svg"
                    class="imgstyle"
                    alt
                  />&nbsp;恢复
                </span>
              </CButton>-->

              <CButton
                class="btn_style system-btn-style"
                @click="updateStatus('stop')"
                id="zhongzhi"
                color="info"
                data-permission="Btn_TaskCenter_Ter"
              >
                <img src="../../assets/icons/stop.svg" class="imgstyle" alt />
                &nbsp;&nbsp;终止
              </CButton>
              <CButton
                class="btn_style system-btn-style"
                id="restartId"
                color="info"
                @click="updateStatus('restart')"
                data-permission="Btn_TaskCenter_Restar"
              >
                <img
                  src="@/assets/icons/start.svg"
                  alt
                  class="imgstyle"
                />&nbsp;&nbsp;重启
              </CButton>
            </div>
          </CCol>
          <div style="height: calc(100% - 116px); width: 100%">
            <TableList
              ref="table"
              :dataList.sync="dataList"
              :getColumn="getColumns"
              :getAxios="getAxios"
              :selectRow.sync="selectList"
              :selection="true"
              :countSelectShow="true"
              :disableSelect="{
                boolean: true,
                label: 'status',
                value: [-1],
              }"
            >
              <template v-slot:taskName="item">
                <div>
                  {{
                    item.data.row.multiImage == "false"
                      ? item.data.row.dataName
                      : item.data.row.taskName
                  }}
                </div>
              </template>
              <template v-slot:show_details2="item">
                <button
                  v-if="item.data.row.status == 1"
                  class="stastusBtn executing"
                >
                  执行中
                </button>
                <button
                  v-if="item.data.row.status == 2"
                  class="stastusBtn pause"
                >
                  暂停
                </button>
                <button v-if="item.data.row.status == 3" style="color: #f9b115">
                  删除
                </button>
                <button
                  v-if="item.data.row.status == 4"
                  class="stastusBtn success"
                >
                  成功
                </button>
                <button
                  v-if="item.data.row.status == 5"
                  class="stastusBtn fail"
                >
                  失败
                </button>
                <button v-if="item.data.row.status == 6" style="color: #f9b115">
                  超时
                </button>
                <button
                  v-if="item.data.row.status == 7"
                  class="stastusBtn stop"
                >
                  停止
                </button>
                <button
                  v-if="item.data.row.status == 8"
                  class="stastusBtn pending"
                >
                  待执行
                </button>
                <button
                  v-if="item.data.row.status == -1"
                  class="stastusBtn pending"
                >
                  未提交
                </button>
              </template>
              <template v-slot:show_details4="item">
                <div
                  v-if="item.data.row.status == 8 || item.data.row.status == 1"
                  class="kkklll"
                >
                  <CSelect
                    :disabled="
                      $store.getters.getBtnProcessPriority &&
                      $store.getters.getBtnProcessPriority.enableFlag == '1'
                    "
                    horizontal
                    :options="priorityShowList"
                    :value.sync="item.data.row.priority"
                    class="prioritySelect1 onButton"
                    data-permission="Btn_TaskCenter_UpP"
                    @change="selectPriorityChange($event, item.data.row)"
                  ></CSelect>
                </div>
                <!-- zmy -->
                <div v-else>
                  {{ item.data.row.priority == 0 ? "普通" : "优先" }}
                </div>
                <!--  <CSelect
                          :disabled="
                    item.data.row.status == 1 || item.data.row.status == 4 || item.data.row.status == 5
                  "
                          horizontal
                          :options="priorityShowList"
                          :value.sync="item.data.row.priority"
                          class="prioritySelect"
                          @change="selectPriorityChange($event, item.data.row)"
                          data-permission="Btn_TaskCenter_UpP"
                  ></CSelect>-->
              </template>
              <template v-slot:progress_item="item">
                <Progress :percent="item.data.row.process" class="cprocssstyle">
                  <span>{{ item.data.row.process + "%" }}</span>
                </Progress>
              </template>
              <template v-slot:show_details="item">

                <Poptip  trigger="hover" word-wrap width="215">

                  <CButton
                      title="监控"
                      variant="outline"
                      class="textBtnStyle system-btn-style"
                      :disabled="item.data.row.status == -1"
                      :class="{ disableTextBtn: item.data.row.status == -1 }"
                      @click="showliftthepunish(item.data.row)"
                  >
                    监控
                  </CButton>
                  <!-- 0 不是人工交互  1是人工交互 -->
                  <CButton
                      :disabled="item.data.row.isHuman == 1 ? false : true"
                      :class="{ disableTextBtn: item.data.row.isHuman !== 1 }"
                      class="textBtnStyle system-btn-style"
                      title="交互"
                      variant="outline"
                      @click="cop(item.data.row)"
                      data-permission="Btn_TaskCenter_MI"
                  >
                    交互
                  </CButton>
                  <!-- <CButton
                    :disabled="true"
                    v-show="noHuman"
                    class="disableTextBtnStyle"
                    title="交互"
                    variant="outline"
                    @click="() => {}"
                    data-permission="Btn_TaskCenter_MI"
                  >
                    交互
                  </CButton>-->
                  <CButton
                      :disabled="
                    item.data.row.status == 1 ||
                    item.data.row.status == 4 ||
                    item.data.row.status == 5 ||
                    item.data.row.status == 6 ||
                    item.data.row.status == 8 ||
                    item.data.row.status == -1
                      ? false
                      : true
                  "
                      :class="{
                    disableTextBtn:
                      (item.data.row.status != 1) &
                      (item.data.row.status != 4) &
                      (item.data.row.status != 5) &
                      (item.data.row.status != 6) &
                      (item.data.row.status != 8) &
                      (item.data.row.status != -1),
                  }"
                      title="删除"
                      variant="outline"
                      class="textBtnStyle system-btn-style"
                      @click="del(item.data.row)"
                      data-permission="BTn_TaskCenter_Del"
                  >
                    删除
                  </CButton>
                  <!--    <CButton
                    :disabled="true"
                    v-if="
                      (item.data.row.status != 8) &
                      (item.data.row.status != 1) &
                      (item.data.row.status != 4) &
                      (item.data.row.status != 5) &
                      (item.data.row.status != 6) &
                      ( item.data.row.status != -1)
                    "
                    title="删除"
                    variant="outline"
                    class="disableTextBtnStyle"
                    @click="() => {}"
                  >
                    删除
                  </CButton>-->
                  <div class="api" slot="content">
                    <CButton
                        title="详情"
                        variant="outline"
                        class="textBtnStyle system-btn-style"
                        :disabled="item.data.row.status == -1"
                        :class="{ disableTextBtn: item.data.row.status == -1 }"
                        @click="getTaskDetails(item.data.row)"
                    >
                      详情
                    </CButton>
                    <!-- <CButton
                        title="下载"
                        :disabled="item.data.row == 8 || item.data.row.status == -1"
                        :class="{
                    disableTextBtn:
                      item.data.row == 8 || item.data.row.status == -1,
                  }"
                        variant="outline"
                        class="textBtnStyle onButton system-btn-style"
                        @click="downloadTaskResult(item.data.row)"
                    >
                      下载
                    </CButton> -->
                  </div>
                </Poptip>
              </template>
            </TableList>
          </div>
        </CCardBody>
      </CCard>
    </div>
    <!-- 质检报告 -->
    <div>
      <QualityReport
        ref="refQcReportModal"
        v-show="qcReportModal"
        :modalShow="qcReportModal"
        @closed="qcReportModalClosed"
      ></QualityReport>
    </div>

    <!-- 修改优先级弹窗 -->
    <CModal
      :show.sync="prioShow"
      :closeOnBackdrop="false"
      title="修改优先级"
      centered
    >
      <template #header class="taskExecuteHeader">
        <img
          src="@/assets/icons/modifyred.png"
          alt
          style="width: 43px; height: 43px; margin-top: -4px"
        />
        <p class="delKuangShow">修改优先级</p>
      </template>
      <div class="modalBody">
        <label
          style="margin-right: 41px; display: inline-block; margin-top: 6px"
          >优先级</label
        >
        <!-- <RadioGroup v-model="priorityData.priority" class="m_radio_group" style="margin-top:6px;"> -->
        <RadioGroup
          v-model="priorityData.priority"
          class="m_radio_group"
          style="margin-top: 6px"
        >
          <Radio label="0">普通</Radio>
          <Radio label="1">优先</Radio>
        </RadioGroup>
      </div>
      <template #footer class="footerBtns">
        <CButton @click="prioShow = false" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="prioOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </CModal>
    <Modal
      v-model="delShow"
      draggable
      scrollable
      title="删除子任务"
      :styles="modalStyle"
    >
      <p slot="header" class="modalHeader">
        <img src="@/assets/icons/shanchu.svg" alt />
        <span style="margin-left: 5px">删除子任务</span>
      </p>
      <div class="modalBody">
        <p>删除子任务时与子任务相关的信息都会丢失</p>
        <p>请确认是否删除?</p>
      </div>
      <template #footer class="footerBtns">
        <CButton @click="delShow = false" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="delOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>
    <!--下载弹框-->
    <Modal
      v-model="showdownLoad"
      draggable
      scrollable
      title="下载列表"
      :styles="modalStyle"
      class="downLoadModal"
    >
      <!-- 复选 : show-checkbox -->
      <Tree
        @on-select-change="selectTree"
        :data="treeData"
        ref="tree"
        class="demo-tree-render"
        style="overflow: auto"
      ></Tree>
      <template #footer class="footerBtns">
        <CButton @click="showdownLoad = false" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="downLoadProduct" color="info" class="system-btn-style"
          >下载</CButton
        >
      </template>
    </Modal>
  </div>
</template>
<!--js代码-->
<script>
import QualityReport from "../qualityCheck/qualityReport";
import TaskDetails from "@/views/taskMonitor/taskDetails.vue";
import TableList from "@/template/table/TableList";
export default {
  name: "taskChildren",
  data() {
    return {
      userName: "",
      showdownLoad: false,
      treeData: [],
      modalStyle: { top: "200px" },
      qcReportModal: false,
      // noHuman: true,
      // isHuman: false,
      userLink: "",
      childPageNum: 0,
      currentPage: 1,
      pages: 0,
      total: 0,
      allNum: 0,
      pageSize: 15,
      Details: true,
      delShow: false,
      clickId: -1,
      // Interaction: true,
      qualityid: 2,
      id: "",
      groupId: "",
      loading: true,
      taskType: 0,
      priority: "0",
      taskStatus: "",
      searchName: "",
      data: [],
      startDate: "",
      endDate: "",
      children: [],
      showchildTask: false,
      groupTaskName: "",
      priorityShowList: [
        {
          label: "优先",
          value: 1,
        },
        {
          label: "普通",
          value: 0,
        },
      ],
      // 修改优先级弹窗
      prioShow: false,
      priorityData: {
        priority: "0",
        startWorkflowId: "",
      },
      pause: true,
      recovery: false,
      selectList: [],
      taskCodeList: [],
      pauseTaskCodeList: [],
      dataList: [],
      getColumns: [
        {
          title: "任务名称",
          key: "taskName",
          slot: "taskName",
          align: "center",
          tooltip: true,
        },
        {
          title: "优先级",
          key: "show_details4",
          slot: "show_details4",
          align: "center",
          width: 90,
        },
        {
          title: "景数",
          key: "imageNumber",
          align: "center",
          width: 80,
        },
        {
          title: "状态",
          key: "show_details2",
          slot: "show_details2",
          align: "center",
          width: 100,
        },
        {
          title: "进度",
          key: "progress_item",
          slot: "progress_item",
          align: "center",
          width: 140,
        },
        {
          title: "开始时间",
          key: "startTime",
          align: "center",
          width: 170,
        },
        {
          title: "结束时间",
          key: "endTime",
          align: "center",
          width: 170,
        },
        {
          title: "执行时间",
          key: "runTime",
          align: "center",
          width: 150,
        },
        {
          title: "操作",
          key: "show_details",
          slot: "show_details",
          align: "center",
          width: 210,
        },
      ],
      getAxios: {
        url: this.$api.taskManageApi.detatilQuery + "/" + this.$route.params.id, //请求路径
        method: "get", //请求方式
        dataList: {}, //请求参数
        firstRequest: false, // 初次不加载
      },

      setInTime: "",
    };
  },
  watch: {
    // pageSize(newVal, oldVal) {
    //   this.pageSize = newVal;
    //   this.getTaskTableData(this.groupId);
    // },
    // currentPage(newVal, oldVal) {
    //   this.currentPage = newVal;
    //   this.getTaskTableData(this.groupId);
    // },
    taskStatus(newVal, oldVal) {
      this.taskStatus = newVal;
      this.getTaskTableData1(this.groupId);
    },
    startDate(newVal, oldVal) {
      this.startDate = this.$moment(newVal).format("YYYY-MM-DD HH:mm:ss");
      this.getTaskTableData();
    },
    endDate(newVal, oldVal) {
      this.endDate = this.$moment(newVal).format("YYYY-MM-DD HH:mm:ss");
      this.getTaskTableData();
    },
    priority(newVal, oldVal) {
      this.priority = newVal;
      this.getTaskTableData();
    },
    dataList: {
      handler(newData) {
        // this.dataListOperate(newData);
        if (
          newData.length != 0 &&
          newData[0].multiImage &&
          newData[0].multiImage == "false"
        ) {
          this.getColumns[2].title = "数据名称";
        }
      },
      immediate: true,
      deep: true,
    },
  },
  mounted() {
    this.userName = window.sessionStorage.getItem("user");
    this.groupId = this.$route.params.id;
    this.groupTaskName = this.$route.params.groupTaskName;
    this.getTaskTableData(this.groupId);
    // 查看子任务后页面的返回上一级路由的改变

    this.childPageNum = this.$route.query.pageNum;
    if (this.$route.query.from === "quality") {
      this.taskType = this.$route.query.taskType;
      this.Details = false;
      // this.Interaction = false;
      this.userLink = "/qualityCheck";
    }
    if (this.$route.query.from === "taskLook") {
      // 任务查询界面
      this.taskType = this.$route.query.taskType;
      this.userLink = "/taskManage/allTask";
    } else if (this.$route.query.from === "taskToExecute") {
      // 待执行任务
      this.taskType = this.$route.query.taskType;
      this.userLink = "/taskManage/taskToExecute";
    } else if (this.$route.query.from === "taskExecute") {
      // 执行中任务
      this.taskType = this.$route.query.taskType;
      this.userLink = "/taskManage/taskExecute";
    } else if (this.$route.query.from === "taskEnd") {
      // 执行结束
      this.taskType = this.$route.query.taskType;
      this.userLink = "/taskManage/taskEnd";
    } else {
      // 暂不处理
    }
    this.setInTime = setInterval(() => {
      this.getTaskTableData(this.groupId);
    }, 10000);
  },
  methods: {
    // 下载产品 客户端下载
    // downloadTaskResult(item) {
    //   if (this.taskType == 2) {
    //     let path =
    //       this.$api.taskManageApi.getDetailProductFileByChildId + item.id;
    //     let param = { userName: this.userName };
    //     this.http.get(path, param).then((res) => {
    //       if (res.data.code == 0) {
    //         let data = res.data.data;
    //         let filePath = data.isFile ? data.file : data.file + "/";
    //         let url =
    //           "DownloadFile://" +
    //           sessionStorage.getItem("PIECloud-Token") +
    //           "/" +
    //           this.userName +
    //           "/" +
    //           filePath +
    //           "/";
    //         if (data.isUserFile) {
    //           let r = window.confirm("暂无影像产品数据,是否跳转根目录？");
    //           if (r) {
    //             this.$$openDownLoadFile(url);
    //           }
    //         } else {
    //           this.$$openDownLoadFile(url);
    //         }
    //       } else {
    //         this.$Message.error(res.data.message);
    //       }
    //     });
    //   } else {
    //     //质量检查详情
    //     this.$refs.refQcReportModal.openOrClose();
    //     this.$refs.refQcReportModal.getTaskDetails(item, "children");
    //   }
    // },

    downLoadProduct() {
      if (!this.productpath) {
        this.$Message.warning("请选择下载的产品文件");
        return;
      }
      /*
        let data = {
          path: this.$api.taskManageApi.isExit,
          params: {
            username: this.$store.state.user.userName,
            path: this.productpath,
            //path:"/pie/data/247/sthx_user_data/pieadmin/lilintest/123/GF3_KAS_QPSI_010970_E81.2_N40.5_20180910_L1A_VH_L10003442728.tif" //测试地址
          },
        };

        let fun = function () {
          let url =
            "DownloadFile://" +
            sessionStorage.getItem("PIECloud-Token") +
            "/" +
            data.params.username +
            "/" +
            data.params.path +
            "/";
          window.location.href = url;
        };
        this.$$downLoadFile(data, fun);
        */
      //原弹框下载
      let newarr = [];
      newarr.push(this.productpath);
      let path = this.GlobalUrlPath.qualityCheck.downloadReport + newarr;
      window.open(path);
    },

    selectTree() {
      let item = this.$refs.tree.getSelectedNodes()[0];
      if (!item) return;
      this.productpath = this.$refs.tree.getSelectedNodes()[0].path;
      if (item.type === "folder") {
        item.expand = !item.expand;
        item.selected = !item.selected;
        return;
      }
    },
    //下载
    downloadTaskResult(item) {
      let _this = this;
      if (/*this.taskType == 2*/ true) {
        //处理加工任务下载
        let path = this.$api.taskManageApi.downLoad + item.id;
        let params = {
          /*productType: this.taskType,*/
          productType: -1,
        };
        this.http.get(path, params).then((res) => {
          if (res.data.code == 0) {
            if (res.data.data.length < 1) {
              this.$Message.warning("暂无影像产品数据");
            } else {
              _this.showdownLoad = true;
              _this.treeData = _this.getNewTreeData(res.data.data);
            }
          } else {
            this.$Message.error(res.data.message);
          }
        });
      } else {
        //质检任务下载
        this.$refs.refQcReportModal.openOrClose();
        this.$refs.refQcReportModal.getTaskDetails(item, "children");
      }
    },

    //提取文件夹里面所有的文件
    getNewTreeData(data) {
      let _this = this;
      let result = [];
      for (let i = 0; i < data.length; i++) {
        let tempItem = data[i];
        let item = {};
        item.expand = tempItem.expand;
        item.path = tempItem.path;
        item.title = tempItem.title;
        item.type = tempItem.type;
        item.children = [];
        result.push(item);

        if (tempItem.type == "folder" && tempItem.children) {
          let list = [];
          _this.recursiveTreeFile(tempItem.children, list);
          item.children = list;
        }
      }
      return result;
    },

    recursiveTreeFile(data, list) {
      let _this = this;
      for (let i = 0; i < data.length; i++) {
        let tempItem = data[i];
        if (tempItem.type == "file") {
          list.push(tempItem);
        }
        if (tempItem.type == "folder" && tempItem.children) {
          _this.recursiveTreeFile(tempItem.children, list);
        }
      }
      return list;
    },

    changeChecked(data) {
      let self = this;

      //行的taskCode值
      let startWorkflowId = data.taskCode;

      //实现选择与取消选择
      let index = self.taskCodeList.indexOf(startWorkflowId);
      if (index == -1) {
        self.taskCodeList.push(startWorkflowId);
      } else {
        self.taskCodeList.splice(index, 1);
      }

      //判断当前勾选的任务类型
      let path =
        this.$api.taskManageApi.queryInfoByWorkFlowId + startWorkflowId;
      this.http.get(path).then((res) => {
        if (res.data.code == 0) {
          if (res.data.data.status == 2) {
            //暂停任务
            let pauseIndex = self.pauseTaskCodeList.indexOf(startWorkflowId);
            if (pauseIndex == -1) {
              self.pauseTaskCodeList.push(startWorkflowId);
            } else {
              self.pauseTaskCodeList.splice(index, 1);
            }
          }
          //如果勾选任务都为暂停任务，界面按钮显示为“恢复”
          if (self.taskCodeList.length == self.pauseTaskCodeList.length) {
            self.pause = false;
            self.recovery = true;
          } else {
            self.pause = true;
            self.recovery = false;
          }
        }
      });
    },
    //工作流的五个状态按钮
    updateStatus(status) {
      if (this.selectList.length == 0) {
        this.$Message.warning("请先勾选子任务！");
        return;
      }
      let path = this.$api.taskManageApi.batchUpdateStatus + status;
      let newTaskCodeList = this.getTaskCodeList(this.selectList);
      let param = newTaskCodeList; //this.taskCodeList;
      this.http.post(path, param).then((res) => {
        if (res.data.code == 0) {
          this.getTaskTableData(this.groupId);
          this.$Message.success(res.data.message);
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },
    getTaskCodeList(data) {
      let result = [];
      data.forEach((element) => {
        result.push(element.taskCode);
      });
      return result;
    },

    //点击“暂停/恢复”按钮

    pauseAndResume(data) {
      if (data == "pause") {
        this.updateStatus("paused");
        this.pause = false;
        this.recovery = true;
      } else if (data == "resume") {
        this.updateStatus("resume");
        this.pause = true;
        this.recovery = false;
      } else {
        this.$Message.error("未知的类型！");
      }
    },

    // dataListOperate(data) {
    //   for (let i = 0; i < data.length; i++) {
    //     this.isHumanTask(data[i].taskCode);
    //   }
    // },
    getTaskTableData(groupId, status) {
      let self = this;
      self.data = [];
      let param = {
        currentPageNum: false,
        status: self.taskStatus,
      };
      if (!(this.groupId === this.$route.params.id) || status) {
        param.currentPageNum = false;
        this.groupId = this.$route.params.id;
      } else {
        param.currentPageNum = true;
      }
      let path = this.$api.taskManageApi.detatilQuery + "/" + groupId;
      let getAxiosData = { url: path };
      self.$refs.table.getRefreshTable(param, getAxiosData);
    },

    getTaskTableData1(groupId) {
      let self = this;
      self.data = [];
      let path = this.$api.taskManageApi.detatilQuery + "/" + groupId;
      let param = {
        currentPageNum: false,
        status: self.taskStatus,
      };
      let getAxiosData = { url: path };
      self.$refs.table.getRefreshTable(param, getAxiosData);
    },
    selectPriorityChange(event, item) {
      let self = this;
      let priority = event.target.value;
      let startWorkflowId = item.taskCode;

      let url =
        self.$api.taskManageApi.updateTask + startWorkflowId + "/" + priority;

      this.http
        .put(url)
        .then((res) => {
          if (res.data.code == 0) {
            this.$Message.success("修改成功");
          } else {
            this.$Message.error(res.data.message);
          }

          // 修改后 刷新右侧table
          self.getTaskTableData(this.groupId);
        })
        .catch((err) => {
          this.$Message.error("修改失败");
        });
    },
    qcReportModalClosed() {
      this.qcReportModal = false;
    },

    getVendorId(event) {
      let tempdata = event.target.value; //获取option对应的value值
      this.pageSize = parseInt(tempdata);
    },
    getTaskDetails(row) {
      // 判断路由  质检 1 处理 2
      if (this.taskType == 2) {
        //处理加工
        this.$router.push({
          path: "/processing",
          query: {
            from: "taskChildren",
            id: row.id,
            taskId: row.groupTaskId,
          },
        });
      } else {
        this.$Message.info("质检任务！");
        //this.$refs.refQcReportModal.openOrClose();
        // this.$refs.refQcReportModal.getTaskDetails(row, "children");
      }
    },
    del(row) {
      this.clickId = row.taskCode;
      this.delShow = true;
    },

    delOk() {
      let path = this.$api.taskManageApi.deleteTaskDetail + "/" + this.clickId;
      this.http.delete(path).then((res) => {
        if (res.data.code == 0) {
          this.delShow = false;
          this.getTaskTableData(this.groupId);
          this.$Message.success(res.data.message);
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },

    prioOk() {
      let self = this;
      let url =
        this.$api.taskManageApi.updateTask +
        this.priorityData.startWorkflowId +
        "/" +
        this.priorityData.priority;

      this.http
        .put(url)
        .then((res) => {
          if (res.data.code == 0) {
            this.prioShow = false;
            this.$Message.success("修改成功");
            // 修改成功后 刷新右侧table
            self.getTaskTableData(this.groupId);
          } else {
            this.$Message.error(res.data.message);
          }
        })
        .catch((err) => {
          this.prioShow = false;
          this.$Message.error("修改失败");
        });
    },
    goBack() {
      this.$router.push({
        path: this.userLink,
        query: {
          from: "taskChildren",
          // pageNum: this.childPageNum,
        },
      });
    },

    changePriority(data) {
      // priority: 0
      // this.priorityDataNew=data.priority
      this.priorityDataNew = `${data.priority}`;

      this.prioShow = true;
      this.priorityData.startWorkflowId = data.taskCode;
    },
    // 获取当前行的data并跳转子页面
    showliftthepunish(data) {
      String.prototype.replaceAll = function (s1, s2) {
        return this.replace(new RegExp(s1, "gm"), s2);
      };

      this.thecurrentdata = data;
      let path = `/taskManage/taskDetails/${data.id}/${data.taskCode}/${
        data.status
      }/${data.taskName.replaceAll("/", "*")}`;
      this.$router.push({ path: path });
    },
    //交互
    cop(item) {
      let myToken = window.sessionStorage.getItem("PIECloud-Token");

      let startWorkflowId = item.taskCode;
      let path =
        this.$api.taskManageApi.childTaskWorkFlow +
        startWorkflowId +
        "/isHumanTaskInProgress";
      this.http.get(path).then((res) => {
        if (res.data.code == 0) {
          let taskId = res.data.data.taskId;
          this.$Message.success(res.data.message);
          let url = "";
          if (res.data.data.algId == "piesat.humantask.measure") {
            //点位量测
            url = "imageinteractive://" + myToken + "/" + taskId + "/";
          } else if (res.data.data.algId == "piesat.humantask.drafting") {
            //专题制图
            url = "CartoInteractive://" + myToken + "/" + taskId + "/";
          } else if (res.data.data.algId == "piesat.humantask.sampling") {
            //参量样本选择
            url = "classifiedinteractive://" + myToken + "/" + taskId + "/";
          } else if (res.data.data.algId == "piesat.humantask.check") {
            //人工质检
            url = "checkinteractive://" + myToken + "/" + taskId + "/";
          } else if (res.data.data.algId == "piesat.humantask.mosaic") {
            // 影像镶嵌
            url = "MosaicInteractive://" + myToken + "/" + taskId + "/";
          } else if (res.data.data.algId == "piesat.humantask.qamodel") {
            //  产品质量分析模块
            url = "QAModelInteractive://" + myToken + "/" + taskId + "/";
          } else if (res.data.data.algId == "piesat.humantask.spatial") {
            //  空间分析与制图
            url = "SpatialInteractive://" + myToken + "/" + taskId + "/";
          } else if (res.data.data.algId == "piesat.humantask.dataloader") {
            //  数据加载
            url = "DataLoaderInteractive://" + myToken + "/" + taskId + "/";
          }else if (res.data.data.algId.includes("piesat.humantask")) {
            let name = res.data.data.algId.split('.')[2];
            url = name + "Interactive://" + myToken + "/" + taskId + "/";
          }
          if (url == "") return;
          window.location.href = url;
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },
    // // 判断当前任务是否有人机交互
    // isHumanTask(taskCode) {
    //   let self = this;
    //   let startWorkflowId = taskCode;
    //   let path =
    //     self.$api.taskManageApi.childTaskWorkFlow +
    //     startWorkflowId +
    //     "/isHumanTaskInProgress";
    //   self.http.get(path).then((res) => {
    //     if (res.data.code == 1) {
    //       self.noHuman = true;
    //       self.isHuman = false;
    //     } else {
    //       self.noHuman = false;
    //       self.isHuman = true;
    //     }
    //   });
    // },
  },
  activated() {
    this.groupTaskName = this.$route.params.groupTaskName;
    this.getTaskTableData(this.$route.params.id);
  },
  deactivated() {
   clearInterval(this.setInTime);
  },
  beforeDestroy() {
    clearInterval(this.setInTime);
  },
  components: {
    TaskDetails,
    QualityReport,
    TableList,
  },
};
</script>

<!--css样式-->
<style scoped>
.myCol {
  margin-left: 10px;
}
.search {
  display: flex;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.76563rem;
  line-height: 1.5;
  border-radius: 0.2rem;
  width: 50px;
}
.table-responsive {
  height: 50% !important;
}
.labelName {
  margin-left: -15px;
  margin-right: 37px;
}
.c-icon {
  margin-bottom: 7px;
}

.btn {
  margin-right: 10px;
}
.headerFont {
  font-size: 18px;
  margin-left: -5px;
}
.goBack {
  margin-top: 15px;
  margin-left: 10px;
  margin-bottom: 15px;
}
.card-body {
  padding: 0px 20px;
}
.cprocssstyle {
  height: 15px;
  margin-left: 2px;
  margin-right: 2px;
}

.goBtn {
  /* margin-right: 10px; */
  width: 25px;
  height: 25px;
  margin-top: -2px;
  margin-right: 7px;
}
.myColPri {
  display: inline-block;
  margin-bottom: 0;
}
.hoverstyle:hover {
  background-color: rgba(0, 0, 0, 0.2);
}

/* 分页 */
.footerPage {
  display: flex;
  justify-content: flex-end;
  cursor: pointer;
  color: black;
}
.pageContent {
  margin-right: 26px;
  font-size: 14px;
}
.selectStyle {
  display: inline-block;
  width: 100px;
  margin-right: 5px;
}
/* xg */
.btnStyle {
  padding: 0;
  margin: 0 5px;
}
.card-body {
  overflow: auto !important;
}
.hoverstyle:hover {
  background-color: rgba(0, 0, 0, 0.2);
}
.btn_style {
  /* background-color: #6d6d6d; */
  border-radius: 4px;
  width: 90px;
  height: 32px;
  margin-left: 15px;
  margin-right: 0;
}
.imgstyle {
  width: 16px;
  height: 16px;
  margin-top: -5px;
  padding-top: 2px;
}
.checkChildTask {
  width: 16px;
  height: 16px;
}
.spanChildTask {
  margin-left: 4px;
}
</style>

<style scoped>
.tempxyz .card-body {
  overflow-y: auto;
  height: calc(100% - 52px) !important;
}

.titleCol {
  display: flex;
  padding: 10px 0;
  justify-content: space-between;
}
.titleCol > div {
  display: flex;
  align-items: center;
}
/deep/ label {
  margin-bottom: 0;
}
/deep/.form-control {
  padding: 0;
}
.kkklll {
  margin: 0;
  width: 100%;
}

/deep/.ivu-table-cell {
  padding-left: 4px;
  padding-right: 4px;
}

/deep/.col-sm-9 {
  margin: 0;
}
</style>
